home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / PacMan / GameActor.m < prev    next >
Encoding:
Text File  |  1992-06-29  |  1.1 KB  |  61 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. // Handles moving and rendering various moving objects.
  5.  
  6. #import "GameActor.h"
  7.  
  8.  
  9. @implementation GameActor
  10.  
  11. - init                // initialize the new instance vars
  12. {
  13.     [super init];
  14.     myX = 0; myY = 0;
  15.     lastx = 0; lasty = 0;
  16.     px = 0; py = 0;
  17.     return self;
  18. }
  19.  
  20. - move:sender                // Move the Actor one animation frame
  21. {    // you must override this and put something here
  22.     return self;
  23. }
  24.  
  25. - at:(float *)xx :(float *)yy        // where is the actor now?
  26. {
  27.     *xx = myX;
  28.     *yy = myY;
  29.     return self;
  30. }
  31.  
  32. - lastAt:(float *)xx :(float *)yy    // called to find out where actor is
  33. {
  34.     *xx = lastx;
  35.     *yy = lasty;
  36.     return self;
  37. }
  38.  
  39. - (int)xpos { return myX; }    // return our x-coord
  40.  
  41. - (int)ypos { return myY; }    // return our y-coord
  42.  
  43. - moveOneFrame    // moves the actor along; access directly or via renderAt::move:
  44. {
  45.     myX += px;
  46.     myY += py;
  47.     return self;
  48. }
  49.  
  50. - renderAt:(int)posx :(int)posy move:(BOOL)moveOk    // draw actor
  51.         // you should lock focus on view that gets the actor first.
  52. {        // this should be overridden by the actor subclass
  53.     if (moveOk) [self moveOneFrame];
  54.     lastx = myX;
  55.     lasty = myY;
  56.     return self;
  57. }
  58.  
  59.  
  60. @end
  61.